<template>
	<view>
	<u-navbar
		title="服务咨询" 
		@leftClick="onClickBack" 
		:placeholder="true"
		:fixed="true"
		:safeAreaInsetTop="true"
		class="nav"
	></u-navbar>
	<view class="content_style">
		
		<view class="item ">
			<view class="w-flex w-flex-between">
				<view>
					客服电话
				</view>
				<view @click="callphone('phone')">
					{{phone}}
				</view>
			</view>
			
		</view>
		<view class="item ">
			<view class="w-flex w-flex-between">
				<view>
					客服电话2
				</view>
				<view @click="callphone('mobile')">
					{{mobile}}
				</view>
			</view>
			
		</view>
		<view class="item ">
			<view class="w-flex w-flex-between">
				<view>
					微信公众号
				</view>
				<view class="w-flex">
					<text style="margin-right: 15px;">易能付聚合</text>
					<text class="copy" @click="copy('123')">复制</text>
				</view>
			</view>
			
		</view>
	</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			info:[],
			mobile:null,
			phone:null,
			gongzhonghao:null
	}
	},
	onShow() {
		this.initData();
	},
	methods: {
		onClickBack () {
			uni.navigateBack()
		},
		
		
		
		callphone (type) {
			if (type==='phone') {
				uni.makePhoneCall({
				  phoneNumber: this.phone
				});
			} else {
				uni.makePhoneCall({
				  phoneNumber: this.mobile
				});
			}
			
		},
		
		async initData () {
			let params = {
				config_name: 'phone'
			}
			const res = await this.$API({url: '/api/common/get_config',method:"GET", data: params})
			if (res.code === 1) {
				this.phone = res.data.value
			} else {
				uni.showToast({
					icon: 'none',
					title: res.msg
				})
			};
			let params1 = {
				config_name: 'mobile'
			}
			const res1 = await this.$API({url: '/api/common/get_config',method:"GET", data: params1})
			if (res1.code === 1) {
				this.mobile = res1.data.value
			} else {
				uni.showToast({
					icon: 'none',
					title: res.msg
				})
			}
		let params2 = {
			config_name: 'gongzhonghao'
		}
		const res2 = await this.$API({url: '/api/common/get_config',method:"GET", data: params2})
		if (res2.code === 1) {
			this.gongzhonghao = res2.data.value
		} else {
			uni.showToast({
				icon: 'none',
				title: res.msg
			})
		}
		
		
		},
	
	copy(value) {
	  uni.setClipboardData({
	      data:this.gongzhonghao ,
	     success: function () {
	     //调用方法成功
	        console.log('success');
	    }
	  })
	 },
	
	
	
	}
}
</script>

<style lang="scss" scoped>
	.content_style {
		height: 100%;
		margin-top: 20rpx;
		.item {
			background: #FFFFFF;
			padding: 20rpx;
			border-top: 1px solid #f1f1f1;
			.copy {
				display: flex;
				align-items: center;
				justify-content: center;
				padding: 2px 20rpx;
				border-radius: 10rpx;
				border: 1px solid #1678ff;
				color: #1678ff;
			}
		}
	}

</style>
